<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%><%-- ${fn:length(list)} --%>
<script src="jquery-1.7.2.js" type="text/javascript" charset="utf-8"></script>
<script>
	$(document).ready(function(){
		$("#itemList").change(function(){
			$.ajax({
				url:"mycinema.do?command=getMyHistory&ajax=true&itemList="+$(this).val(),
				dataType:"json",
				success:function(js){
					var table="<table border='1' width='100%'><tr align='center' bgcolor='#f5f5f5'>	<td>영화제목</td><td>영화관</td><td>매수</td><td>좌석번호</td>	<td>상영일</td>"+
					"<td>상영시간</td><td>결재방식</td><td>결재금액</td><td>결재시간</td><td>구매유무</td></tr>";
					$.each(js.list.list,function(index,value){
						table +="<tr align='center'><td>"+value.MOVIE_TITLE+"</td><td>"+value.LOC+"-"+value.THEATER+"-"+value.PLAY_ROOM_NO+"관</td>"+
							"<td>"+value.TICKET_COUNT+" 매</td><td>"+value.SEAT_NO+"</td><td>"+value.DAY+"</td><td>"+value.STARTING_TIME+"~"+value.ENDING_TIME+"</td>"+
							"<td>"+value.PAYMENT+"</td><td>"+value.PRICE+"</td><td>"+value.CONFIRM_DAY+"</td><td>";
							if(value.IS_CANCELED=='y')	table+="<font color='blue'>예매</font></td></tr>";
							else	table+="<font color='red'>취소</font></td></tr>"; 
					});
					table+="</table>";
					$("#list").html(table);
					var paging="";
					if(js.list.pagingBean.previousPageGroup){
						paging+="<a href='mycinema.do?command=getMyHistory&itemList="+$("#itemList").val()+"&page="+js.list.pagingBean.startPageOfPageGroup-1+"'><img src='img.board/left_arrow_btn.gif'></a>";
					}
					paging+="&nbsp;&nbsp;";
					for(i=js.list.pagingBean.startPageOfPageGroup;i<=js.list.pagingBean.endPageOfPageGroup;i++){
						if(js.list.pagingBean.nowPage!=i) 
							paging+="<a href='#' class='pageclick'> "+i+" </a>";
							/* paging+="<a href='mycinema.do?command=getMyHistory&itemList="+$("#itemList").val()+"&page="+i+"'> "+i+" </a>"; */
						else 
							paging+=" <u>"+i+"</u> ";
					}
					paging+="&nbsp;&nbsp;";
					if(js.list.pagingBean.nextPageGroup)
						paging+="<a href='mycinema.do?command=getMyHistory&itemList="+$("#itemList").val()+"&page="+js.list.pagingBean.endPageOfPageGroup+1+"'><img src='img.board/right_arrow_btn.gif'></a>";
					$("#paging").html(paging);
				}
			});// itemList change ajax
		}); // itemList change
		$(".pageclick").click(function(){
			alert($(this).text());
			$.ajax({
				url:"history.do?command=123123&page="+$(this).text()+"&work_order_id=1_23132",
				dat
				sycsc functi
					tboydy
					$.each()
					lvo, pagignBean
			});
		});
	}); // ready
</script>
<c:choose>
<c:when test="${sessionScope.vo==null}">
<script>
	alert("로그인 하세요!");           
	location.href="mycinema.do?command=home_main";
</script>
</c:when>
<c:otherwise>
<span class="title">예매/취소 내역</span><hr color="#f5f5f5">
<select id="itemList">
	<option value="all">전체내역</option>
	<option value="buy">구매내역</option>
	<option value="sell">취소내역</option>
</select>
<div id="list">
<table border="1" width="100%">
	<tr align="center" bgcolor="#f5f5f5">
		<td>영화제목</td>
		<td>영화관</td>
		<td>매수</td>
		<td>좌석번호</td>
		<td>상영일</td>
		<td>상영시간</td>
		<td>결재방식</td>
		<td>결재금액</td>
		<td>결재시간</td>
		<td>구매유무</td>
	</tr>
	<c:forEach items="${requestScope.list.list }" var="list">
	<tr align="center">
		<td>${list.MOVIE_TITLE }</td>
		<td>${list.LOC }-${list.THEATER }-${list.PLAY_ROOM_NO }관</td>
		<td>${list.TICKET_COUNT }매</td>
		<td>${list.SEAT_NO }</td>
		<td>${list.DAY }</td>
		<td>${list.STARTING_TIME}~${list.ENDING_TIME }</td>
		<td>${list.PAYMENT }</td>
		<td>${list.PRICE} </td>
		<td>${list.CONFIRM_DAY} </td>
		<td><c:if test="${list.IS_CANCELED=='n'}"><font color='red'>취소</font></c:if>
		<c:if test="${list.IS_CANCELED=='y'}"><font color='blue'>예매</font></c:if></td>
	</tr>
	
	</c:forEach>
</table>
</div>
<div id="paging">
	<!-- 페이징 처리 -->	
	 <c:if test="${requestScope.list.pagingBean.previousPageGroup}">
	 	<a href="mycinema.do?command=getMyHistory&page=${requestScope.list.pagingBean.startPageOfPageGroup-1}">
 		<img src="img.board/left_arrow_btn.gif"></a>
 	</c:if> &nbsp;&nbsp;
	<c:forEach var="i" begin="${requestScope.list.pagingBean.startPageOfPageGroup}" end="${requestScope.list.pagingBean.endPageOfPageGroup}">
 		<c:choose>
 			<c:when test="${requestScope.list.pagingBean.nowPage!=i}">
				<a href="mycinema.do?command=getMyHistory&page=${i}">${i}</a>
			</c:when>
			<c:otherwise><u>${i}</u></c:otherwise>
		</c:choose>
	</c:forEach>&nbsp;&nbsp;
	<c:if test="${requestScope.list.pagingBean.nextPageGroup}">
  		<a href="mycinema.do?command=getMyHistory&page=${requestScope.list.pagingBean.endPageOfPageGroup+1}">
 			<img src="img.board/right_arrow_btn.gif"></a> 
 	</c:if>	 	
</div>
</c:otherwise>
</c:choose>